Skip to content

Instantly share code, notes, and snippets.

@mouse0270
Last active January 20, 2019 16:19
Show Gist options
  • Save mouse0270/697daf1b2cb835c7995a9c1ad46861c3 to your computer and use it in GitHub Desktop.
Save mouse0270/697daf1b2cb835c7995a9c1ad46861c3 to your computer and use it in GitHub Desktop.
Defer Inline Javascript
// With $script variable
$(document).ready(function() {
$('script[type="text/javascript/defer"]').each(function() {
var $script = $('<script type="text/javascript"/>').text($(this).clone().text());
$(this).after($script).remove();
});
});
// Without $script variable
$(document).ready(function() {
$('script[type="text/javascript/defer"]').each(function() {
$(this).after($('<script type="text/javascript"/>').text($(this).clone().text())).remove();
});
});
// Minified
$(document).ready(function(){$('script[type="text/javascript/defer"]').each(function(){$(this).after($('<script type="text/javascript"/>').text($(this).clone().text())).remove()})});
@vinayaketx
Copy link

How to defer inline JAVASCRIPT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment