Log in

Inline your Javascripts


Staff member
Sep 29, 2016
Do your web pages load one or several Javascript files? Then there’s a good chance you can speed your website up by optimizing the Javascript delivery. Read more below.

How inlining Javascripts can benefit performance
Every time a visitor loads a web page in a browser they need to request, download and execute your Javascript files in order to correctly display your website. These requests can be render-blocking, especially when there's a lot of them. Inlining your Javascripts will eliminate this problem as the browser no longer has to make multiple download requests and you allow the browser to instantly render your HTML page without having to load additional files. CSS files should preferably be inlined as well.

Only smaller Javascripts

When you have lots of (or very large) Javascripts it’s better to still use a file to call them from your web page. The best practice for larger Javascripts is to copy and paste all of them in one bigger file. This way the browser only has to request one file instead of multiple ones, which speeds up your website due to the lower amount of HTTP requests.

How to inline Javascripts
1. Copy the Javascripts you want to inline (remember, only smaller Javascripts) and combine all of theme into one bigger script
2. Place the script within <script type="text/javascript"></script> tags
3. Place all of it within the HTML </head></head> tags of your web page
Below is an example of how this may look:
<script type="text/javascript">

Compress Javascript code
When you really want to optimize your Javascripts in the best way possible you can compress them with the Javascript Compressor. This compressor can be used to minimize your Javascript size, combine multiple Javascript files and detect errors as well.

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Community Posts

Public Zone Posts

About us

  • NulledFire.com is one of the most comprehensive repositories under the terms of GPL (GNU General Public License v3.0 Free as in Freedom) that provides premium Plugins, Themes and PHP Scripts for testing purposes.
    We promote WP codes to the users globally so that you can check it before buying from the original developer/designer.

User Menu

NulledFire Statistics

Latest member