Reputation: 27
I am trying to optimize a piece of JS (it's a company details - address, phone number etc. verification badge). I really don't need it, but it pulls info from two different CDN's, which adds up to my page speed.
The line looks like this:
<script src="https://d20iczrsxk7wft.cloudfront.net/botwverified/badge.js?id=1234567"></script>
It is possible (jquery is already loaded for other stuff) to make this appear, or load, only after the page completely loaded? Probably JS? I know nothing about JS. My page loads in 1.5 second and this badge takes an extra second load.
Thank you!
Upvotes: 0
Views: 58
Reputation: 780723
You can use jQuery to load the script dynamically.
<script>
$(document).ready(function() {
$.getScript("https://d20iczrsxk7wft.cloudfront.net/botwverified/badge.js?id=1234567");
});
</script>
The ready()
function calls the function after the page is loaded.
Upvotes: 4