Code Minification and why you should use it.

Discussion Of All Legal Topics Is Fine Anything Goes. Be Respectful of Others. No Personal Information or Attacks.
All Traffic, Link, Banner, Push Notification and Advertising, Offers & Requests Here,.
Domains & Websites For Sale and Requests Here.
Keep One thread per person & No More Than 1 Weekly Bump.
Post Reply
sebflo
Verified Member
Verified Member
Posts: 138
Joined: October 9th, 2018, 1:16 pm

Code Minification and why you should use it.

#1

Post by sebflo » November 7th, 2018, 2:34 pm

I personally minify all my JS and CSS. Its a simple step that gives you faster performance by providing less bytes to be downloaded on the client side. This is useful when you have a process heavy website.

Here is a simple example.

Not minified code

Code: Select all

let number = dynamicData.number;
function checkNum(num){
    if(num < 5){
        return num;
    }else{
        return err.msg;
    }
}

checkNum(number);
Same code as above but minified

Code: Select all

let number=dynamicData.number;function checkNum(num){if(num<5){return num}else{return err.msg}}
checkNum(number)
If I have multiple javascript and css file then I use a code bundler than combines all my code into a single file that is minified that I simply include in my websites html files.

Alternatively you can uglify your code which will add some security to your code by making it unreadable to anyone trying to see what client side code is running on your website.




Colmike7
Banned
Banned
Posts: 1670
Joined: May 23rd, 2018, 12:21 pm
Title: (>^-^)b

#2

Post by Colmike7 » November 7th, 2018, 2:40 pm

Does taking out spaces and line breaks really make that much of a difference with bytes saved? I've heard of that before, but I've never really analyzed it.
I do like the way the minified code looks, too.

A lazy way to uglify code is to just use base64 and eval(base64_decode()).. :p But that causes other problems..




sebflo
Verified Member
Verified Member
Posts: 138
Joined: October 9th, 2018, 1:16 pm

#3

Post by sebflo » November 7th, 2018, 2:49 pm

Colmike7 wrote: ↑
November 7th, 2018, 2:40 pm
Does taking out spaces and line breaks really make that much of a difference with bytes saved? I've heard of that before, but I've never really analyzed it.
I do like the way the minified code looks, too.

A lazy way to uglify code is to just use base64 and eval(base64_decode()).. :p But that causes other problems..
It actually does, if you run a linux based server check out glances and also check out the network monitor in chrome when you load your page.

An even lazier yet more efficient way to minify/uglify is to use webpack or any of the other minifi/uglify tools that are on NPM.

It may not make a difference at first but once you have tons of traffic and content, it can make a huge difference.

I use it a lot when making non-refreshing applications that use things like ajax to bring in data without refreshing pages.




User avatar
viking
Verified Member
Verified Member
Posts: 1419
Joined: March 18th, 2018, 8:28 pm

#4

Post by viking » November 8th, 2018, 9:27 am

What is the fastest available code these days, is it php.




Colmike7
Banned
Banned
Posts: 1670
Joined: May 23rd, 2018, 12:21 pm
Title: (>^-^)b

#5

Post by Colmike7 » November 8th, 2018, 9:33 am

viking wrote: ↑
November 8th, 2018, 9:27 am
What is the fastest available code these days, is it php.
Depends on what you're doing. I could make a page <html><head /><body>hi</body></html> and claim that it's the fastest.. :p




User avatar
viking
Verified Member
Verified Member
Posts: 1419
Joined: March 18th, 2018, 8:28 pm

#6

Post by viking » November 8th, 2018, 9:34 am

Colmike7 wrote: ↑
November 8th, 2018, 9:33 am
viking wrote: ↑
November 8th, 2018, 9:27 am
What is the fastest available code these days, is it php.
Depends on what you're doing. I could make a page <html><head /><body>hi</body></html> and claim that it's the fastest.. :p
smart ass :lol:

I mean for a site like a blog aka WP




User avatar
TheButcher
Administrator
Administrator
Posts: 17522
Joined: February 2nd, 2018, 11:48 am
Title: I like weekends
Referrals: 1
Contact:

#7

Post by TheButcher » November 9th, 2018, 1:24 pm

2 things I never mastered, code and design. Actually make that 3 things, I still type like a bat out of hell with 2 index fingers.

sebflo
Verified Member
Verified Member
Posts: 138
Joined: October 9th, 2018, 1:16 pm

#8

Post by sebflo » November 9th, 2018, 2:29 pm

viking wrote: ↑
November 8th, 2018, 9:27 am
What is the fastest available code these days, is it php.
For backend concurrent development I think PHP might be the a good choice, depending on the tasks its doing it will sometimes be considered the fastest.

However that does not mean reliable all the time, its great for tasks that dont take minutes or days to complete. For example I have some event handlers and listeners I created for a huge projects using mobile communications hardware that I wrote in JAVA, its continuously running 24/7 with no errors for the past 9 months. Using PHP for something like this would not be fun.

For asynchronous front-end development javascript is a great choice, using javascript (vanilla or otherwise) along with a REST API for data in and out, developed in PHP, Python, or really any other backend language would give you great results.

I know Node.js has been coming along for a while, personally I don't feel its mature enough yet to consider for production.




User avatar
shoopa
Verified Member
Verified Member
Posts: 1851
Joined: February 26th, 2018, 7:32 pm

#9

Post by shoopa » November 10th, 2018, 4:19 pm

Simplifying code is always appreciatd




deviantz
Verified Member
Verified Member
Posts: 877
Joined: March 11th, 2018, 1:47 pm

#10

Post by deviantz » November 11th, 2018, 10:02 am

I never knew line breaks and white spaces could affect load times. Thanks for sharing this.




User avatar
jag
Verified Member
Verified Member
Posts: 6527
Joined: February 15th, 2018, 9:51 am
Title: From Malta with love
Referrals: 1

#11

Post by jag » November 12th, 2018, 8:36 am

You boys are smart, well done
From Malta with love and sunshine

ezdoesitz
Verified Member
Verified Member
Posts: 483
Joined: April 8th, 2018, 6:37 pm

#12

Post by ezdoesitz » November 13th, 2018, 4:02 pm

All you intelligent people have me working today. Working my sites one by one to reduce wasted characters and spaces.




fetishnews
Verified Member
Verified Member
Posts: 1336
Joined: February 16th, 2018, 6:30 pm

#13

Post by fetishnews » November 14th, 2018, 8:30 pm

ezdoesitz wrote: ↑
November 13th, 2018, 4:02 pm
All you intelligent people have me working today. Working my sites one by one to reduce wasted characters and spaces.
welcome to the internet circa 2018 :idea:




User avatar
badkitty
Verified Member
Verified Member
Posts: 1431
Joined: February 6th, 2018, 11:33 am

#14

Post by badkitty » November 16th, 2018, 9:32 am

You guys like or use "url shortner" links?




pornmafia
Verified Member
Verified Member
Posts: 1303
Joined: March 4th, 2018, 12:14 pm

#15

Post by pornmafia » November 17th, 2018, 11:00 am

badkitty wrote: ↑
November 16th, 2018, 9:32 am
You guys like or use "url shortner" links?
No because if the site goes down then my links are screwed.




Code Minification and why you should use it.

Post Reply