Making an HTTP request to undefined
is the equivalent of requesting the same page again ('.'
or window.location.href
). The examples below were found in three out of three front-end performance audits we performed for clients at Lincoln Loop over the last two weeks.
Last active
August 29, 2015 14:24
-
-
Save ipmb/d90d8562c38b1239cbe5 to your computer and use it in GitHub Desktop.
How to Double your Traffic with 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
/* | |
* Make an XHR to a variable that is undefined | |
*/ | |
var settings = { | |
urlForThis: '...', | |
// urlForThat: '...' | |
}; | |
$.get(settings.urlForThat); | |
/* | |
* Variation of the same theme | |
*/ | |
var url = $elem.attr('href'); // DOM element does not exist | |
$.getJSON(url); | |
/* | |
* Set an image source to an undefined variable | |
*/ | |
var img = new Image(); | |
var largeSrc = $imgObj.data('large-version'); // this data attribute does not exist | |
img.src = largeSrc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment