Quick tip: Javascript Linking Secrets


Javascript has become the lifeline of the modern web. Without javascript, there would be so much less interaction on your websites, that it’s unimaginable. No nice forms, no popups,  no ads, no monetization, etc. But with the modern need of the hour of fast loading websites, how do we get the best of both worlds. I’ll show you how :-

Even with the heavy size of the javascript files, there is a way you can get your webpage to load faster.

There is a theory, an old one, that if you link your javascript in the footer, the webpage will load faster. Well, it’s true, as, even if the javascript has not loaded, the rest of the webpage will be there as it is. This means, your important information will be displayed, even if your javascript files have not loaded. Code sample below:-

<html>
<head>
...
</head>
<body>
Other important stuff !!!
<!-- load javascript files after the important info -->
<script type="text/javascript" src="link to .js file">
</scipt>
</body>
</html>

So, as you can see, in the code example above, I’ve loaded the javascrript below the ending of the </body> tag. This way, only after the content has loaded, will the .js file load, not causing any problems.

Side note: There is also one other way of going about this. That is using a CDN. Though this is costly, it will be really helpful. A CDN, takes all the heavy objects in a web page, like images, js files, css files and uploads them to their server, supplying it when you need it. As CDN’s have servers located at a lot more locations than your server, they will help your site load faster at more physical distance from your servers.

There you have it guys, 2 ways of Javascript Linking secrets, as promised.

What do you think of the techniques ? Tell me in the comments below.

NEW! Get every new mail delivered in your inbox

Enter your email address to follow this blog and receive notifications of new posts by email.

2 thoughts on “Quick tip: Javascript Linking Secrets

Add your Awesome voice. Let's have a meaningful conversation. And remember, don't be a spammer (We hate 'em).

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s