Genesis Themes

  • Home
  • Genesis Tutorials
  • WP Tutorial
  • Twenty Fifteen Theme
  • Social Media
  • WP Plugins

How to Inline Small JavaScript Files

Inline Small JavaScript Files

Inline JavaScript is a advanced technique to speedup your website.Put your JS into HTML file instead of keeping it on external JS file.So,it will reduce the files the browser has to download and display user requested page.Many developers apply inline JavaScript for website homepage only.Because of it has to be load fast.For rest of the website pages,they use several external JavaScript files.This is really not good for pagespeed,so prefer inline JavaScript for entire site.

If you use an external JS file,than browser first loads HTML file and again it lookups to download files from  external JS files.Server getting extra requests from the browser,your website takes some extra ms to display page,it has to take time to download files.

How to Inline JavaScript

To Inline Small JavaScript,you need not to work hard,it's pretty simple method.First copy the content of external JS file and paste it in your HTML file.This code should be added between script tags in head section as shown in below.

<script type="text/javascript">// <![CDATA[
PASTE YOUR JAVASCRIPT CODE HERE
// ]]></script>

Putting your external js file content into head section of your HTML file is not only reduces extra file but also saves time to browser to download files from one js only.It's a best practice to reduce the server time.After implementing this technique just checkout your page speed in Google page speed and YSlow.The code should be added properly in order to get success of Inline JS.If you are using WordPress,then your site might have more than 3 to 5 external JS files,simply copy them all and paste in between scripts tags in HTML section.

Related Posts

  • Manually Display Disqus Comment Count in WordPress
  • Resources to Minify CSS in WordPress
  • How to Add Related Posts with Thumbnails in WordPress
  • No Self Pings : 2 ways to Remove WordPress Self Pingbacks
  • Speed Up Your WordPress Cache Without Plugins
  • How to Add Expires Headers in WordPress
  • Exclude Category Posts from Homepage in WordPress
  • Setting Up WordPress Breadcrumbs with Yoast SEO Plugin
  • WordPress : Remove Transient Options in Database
  • How to Remove Elegant Themes Footer Links

Bluehost and Siteground Coupons for January 2016.

Best Premium WordPress Themes from TemplateMonster
download wordpress themes from MonsterOne

Categories

  • Blog
  • Blogger
  • Genesis Tutorials
  • Social Media
  • Top Websites
  • Twenty Fifteen WordPress Theme
  • WordPress Plugins
  • WordPress Tutorial