8. Inject Content with JSONP Create one hidden element Send JSONP request When JSONP data is received, compose HTML Fill the hidden element with composed HTML Show hidden element
43. /* * Gets query string presentation of given object. */ functiontoQueryString(params) { varencParams = [], encode = encodeURIComponent; for(key in params) { encParams.push(encode(key) + '=' + encode(params[key])); } return encParams.join('&'); } functiontoQueryString(c){var a=[],b=encodeURIComponent;for(key in c){a.push(b(key)+"="+b(c[key]))}returna.join("&")}; Keywords are NOT Minified
44. /* * Gets query string presentation of given object. */ function toQueryString(params) { varencParams = [], encode = encodeURIComponent; for(key in params) { encParams.push(encode(key) + '=' + encode(params[key])); } return encParams.join('&'); } function toQueryString(c){var a=[],b=encodeURIComponent;for(key in c){a.push(b(key)+"="+b(c[key]))}returna.join("&")}; Global Variables are NOT Minified
45. /* * Gets query string presentation of given object. */ function toQueryString(params) { varencParams = [], encode = encodeURIComponent; for(key in params) { encParams.push(encode(key) + '=' + encode(params[key])); } return encParams.join('&'); } function toQueryString(c){var a=[],b=encodeURIComponent;for(key in c){a.push(b(key)+"="+b(c[key]))}returna.join("&")}; Object Properties are NOT Minified
46. /* * Gets query string presentation of given object. */ function toQueryString(params) { varencParams = [], encode = encodeURIComponent; for(key in params) { encParams.push(encode(key) + '=' + encode(params[key])); } return encParams.join('&'); } function toQueryString(c){var a=[],b=encodeURIComponent;for(key in c){a.push(b(key)+"="+b(c[key]))}returna.join("&")}; How About This?
47. Wait, Do We Need Minify If All Browsers Support Gzip?
52. YABC = { privateVariable: ‘hello’, privateFunction: function() { // do some private thing }, load: function() { // do something } };
53. YABC = { privateVariable: ‘hello’, privateFunction: function() { // do some helping }, load: function() { // do something } }; Not Minifiable
54. (function() { var _privateVariable = ‘hello’; function _privateFunction () { // do some private thing } YABC = { load: function() { // do something } }; }()) Immediate Function Pattern
55. (function() { var_privateVariable= ‘hello’; function _privateFunction() { // do some private thing } YABC = { load: function() { // do something } }; }()) Minifiable
56. (function() { var win = window; _privateVariable = ‘hello’; function _privateFunction () { // do some private thing } YABC = { load: function() { // do something } }; }()) “window” is used more than once
57. (function() { var win = window; _privateVariable = ‘hello’; function _privateFunction () { // do some private thing } YABC = { unload: function() { }, load: function() { // do something } }; }())
58. (function() { var win = window; _privateVariable = ‘hello’; function _privateFunction () { // do some private thing } YABC = { unload: function() { }, load: function() { // do something } }; }()) Every invocation of this method has to be “YABC.unload”
59. (function() { var win = window; _privateVariable = ‘hello’, yabc; function _privateFunction () { // do some private thing } varyabc= { unload: function() { }, load: function() { // do something } }; YABC = yabc; }()) Local Invocation of “yabc.unload” can be minfied
60. (function() { var win = window; _privateVariable = ‘hello’, yabc; function _privateFunction () { // do some private thing } varyabc= { unload: function() { }, load: function() { // do something } }; YABC = yabc; }()) YUI Developers, Looks Familiar?