Web3 platform that empowers users with seamless earning opportunities. Our mission is to make life changing rewards accessible to everyone in just minutes a day
Play🕹️: @realyescoinbot
Business: @advertize_support
Last updated 1 year, 8 months ago
Fast transfers & trading, send meme gifts 🎁 and earn 100x returns — fun and flexible crypto app!
Incubated & invested by Binance Labs
Https://grandjourney.io
Last updated 1 year, 8 months ago
When you optimizing size keep in mind that final result will be gziped before network transfer. Every comparision must be done after compression.
Let's see an example.
This is a function to detect if browser has SVG support or not:
(function(d,n){d.documentElement.className="ua_svg_"+(d[n]&&d[n]("http://www.w3.org/2000/svg","svg").createSVGRect?"yes":"no")})(document,"createElementNS")
At first look you may consider that this is optimal solution and there is nothing to improve there. We used function, passed repeated parts as one letter params.
We can do better! The code below is bigger (161 bytes versus 157), but after gzip it is smaller (126 bytes versus 154):
document.documentElement.className=document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect?"ua_svg_yes":"ua_svg_no"
And it is easier to read IMHO.
The same for the code which detects retina display:
(function(w,e,s,c,x,l,p,d){c="className";x="deviceXDPI";l="logicalXDPI";p="devicePixelRatio";d=x in s&&l in s&&s[x]/s[l]||p in w&&w[p];d>1&&(e[c]+=" i\-ua_retina_yes")})(window,document.documentElement,screen)
After "de-optimizing" it is smaller and easier to read (191 byte versus 125):
(screen.deviceXDPI&&screen.logicalXDPI&&screen.deviceXDPI/screen.logicalXDPI||window.devicePixelRatio)>1&&(document.documentElement+=" i\-ua_retina_yes")
Notes about web site optimizations, based on my tasks on optimizing Yandex search result page.
Web3 platform that empowers users with seamless earning opportunities. Our mission is to make life changing rewards accessible to everyone in just minutes a day
Play🕹️: @realyescoinbot
Business: @advertize_support
Last updated 1 year, 8 months ago
Fast transfers & trading, send meme gifts 🎁 and earn 100x returns — fun and flexible crypto app!
Incubated & invested by Binance Labs
Https://grandjourney.io
Last updated 1 year, 8 months ago