Gulp: Work in progress, newbie needs support please
Moderator: General Moderators
Re: Gulp: Work in progress, newbie needs support please
If you're looking at further improving load times, take a look at this http://betterexplained.com/articles/how ... mpression/
Re: Gulp: Work in progress, newbie needs support please
Just be careful not to fall into the trap of micro-optimization.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Gulp: Work in progress, newbie needs support please
Does this happen with CSS too?No. Minifying it would actually use more space as you'd have two copies of the file; one minified, one not.
I'm a bit lost again as to how to use Gulp for minifying.
I assume you use it to reduce it all down, and then you uplod that file INSTEAD of the old (larger) CSS file.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Gulp: Work in progress, newbie needs support please
Yes, that's right. The benefit isn't to reduce disk space used, which would be a very marginal gain, but to reduce the size of the payload the client is pulling down, thereby improving load times. As PHP isn't sent to the client, minifying PHP provides no benefit. Gzipping the resultant HTML can.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Gulp: Work in progress, newbie needs support please
So what do I do with the contents of my dist folder?
So I use those files, instead of the current CSS files?
As the way I read you rmessage, I have to upload BOTH files for some reason.
So I use those files, instead of the current CSS files?
As the way I read you rmessage, I have to upload BOTH files for some reason.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Gulp: Work in progress, newbie needs support please
Yes. Have one directory for human-readable, easily editable files, and one containing the minified versions that you actually use in your site.simonmlewis wrote:So what do I do with the contents of my dist folder?
So I use those files, instead of the current CSS files?
You don't need to. Doesn't really matter one way or the other. What's important is that the client be pulling down the minified files.simonmlewis wrote:As the way I read you rmessage, I have to upload BOTH files for some reason.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Gulp: Work in progress, newbie needs support please
So locally, I run Gulp which minifies CSS and JS (so far), and I edit Gulp first I guess to make sure it uses the same filenames too! (easier).
Then I upload only the dist folder files to their relevant places on the live server.
Thus not specifically reducing file sizes, but because there is less to "read" in the files, they take less time to load.
I suppose to do a "manual" version of this minifying, I should reduce the white space where poss in my index.php file and others.
Then I upload only the dist folder files to their relevant places on the live server.
Thus not specifically reducing file sizes, but because there is less to "read" in the files, they take less time to load.
I suppose to do a "manual" version of this minifying, I should reduce the white space where poss in my index.php file and others.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Gulp: Work in progress, newbie needs support please
Rightsimonmlewis wrote:So locally, I run Gulp which minifies CSS and JS
I suppose, if you like. Personally, I'd just edit site.js and set my script src to site.min.js and so forth.simonmlewis wrote:and I edit Gulp first I guess to make sure it uses the same filenames too! (easier).
No, the minified files are measurably smaller. A space is still a character, as is a tab.simonmlewis wrote:Thus not specifically reducing file sizes, but because there is less to "read" in the files, they take less time to load.
No. Keep your files legible. You're going to need to go back and edit them. As I have already stated, minifying PHP will yield precisely zero benefit. Set up Gzip compression in Apache if you want to reduce the size of what's being sent over the wire.simonmlewis wrote:I suppose to do a "manual" version of this minifying, I should reduce the white space where poss in my index.php file and others.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Gulp: Work in progress, newbie needs support please
I understand about the PHP, as if you have aton of code, and then "echo 'hello'", the "hello" is all that is actually loaded up.
In the dist folder are two js files. all.js and all.min.js. Which is the one that I use?
reading the gulp file, it's all.min.js.
In the dist folder are two js files. all.js and all.min.js. Which is the one that I use?
reading the gulp file, it's all.min.js.
Code: Select all
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src('js/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('dist'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Gulp: Work in progress, newbie needs support please
Yes, that's right.simonmlewis wrote:reading the gulp file, it's all.min.js.