Last active
January 20, 2019 16:19
-
-
Save mouse0270/697daf1b2cb835c7995a9c1ad46861c3 to your computer and use it in GitHub Desktop.
Defer Inline Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()})}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to defer inline JAVASCRIPT?