Mobile app version of vmapp.org
Login or Join
Vandalay111

: Page Speed Optimization Questions: defer parsing and specifying a char set? Continuing to optimized a web site, I'm using Chrome's Dev Tool add-on for Page Speed. I've been able to do a good

@Vandalay111

Posted in: #Html #MetaTags #Optimization #PageSpeed

Continuing to optimized a web site, I'm using Chrome's Dev Tool add-on for Page Speed.

I've been able to do a good bit of performance tuning thanks to its suggestions, but these two have me perplexed:

I'm being told I need specify character set, but I have this in all my documents (meta tag below). It's within the head, does it need to be done prior to the HTML tag? If so, what's the syntax?

<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />


Second one I'm getting dinged on is deferring of Javascript.

I know back in the day you could add a defer="defer" to the JS, but I don't think that's valid, nor does that satisfy the Page Speed validators. How do I defer JS?

Typically my sites have jQuery linked to Google's CDN, and then an overarching local site.js loaded right after the jQuery core, like so:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="/lib/js/site.js"></script>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Vandalay111

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cofer257

Ideally, the Content-type should be specified in HTTP headers (and the text/html part almost certainly is). Failing that, the declaration must be within the first 1024 bytes (usually 1024 characters) of the document.

The best way to ensure this is putting it right after the <head> tag. If you are using HTML5 you can simply use <meta charset="utf-8">.

For Javascript, the best way to effectively "defer" it is to place the scripts at the bottom of the page, before </body>. This way the page will load and not be held back by scripts loading.

This may not be easily possible in some site architectures, so do not worry if it's not. Just keep the number and size of scripts to a reasonable level.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme