-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This repository is part of a larger project!
It is important to understand that the strict mode works only on top of a script or function. This trait should be taken in consideration when concatenating code from more than one different js files.
The sensitivity to script concatenation can be tested with the files in folder "example1" and "example2" which can be found in the code section in this github project. Note that all files should be kept in the same folder so that the function of the code is guaranteed.
The content of two files were merged into one file with the help of gulp. These files are "no strict.js" and "strict.js".
Gulp is a toolkit for automating time consuming processes in developement. There are very well made tutorials based on grunt and gulp. Here are some recommendable on youtube by Tech CBT:
In the file "README_TO_GULP.txt" is a quick explanation how to install and use gulp for this project.
To concatenate the two files "no strict.js" and "strict.js", a file "gulpfile.js" is needed which can be downloaded from the code section of this github project. If not interested, there is no need to make all the work, because "example1" and "example2" contain already the results.
This contains the concatenated js code in the following sequence.
- first - "no strict.js"
- second - "strict.js"
The consequence is that the strict mode has no effect.
This contains the concatenated js code in the following sequence.
- first - "strict.js"
- second - "no strict.js"
The consequence is that the strict mode is activated.
There are two solutions for this kind of problem
- Avoid concatenating strict with nonstrict files and vice versa
- Wrap the body of the concatenating files - Project
This knowledge was gained:
-
Effective JavaScript "68 Specific Ways to Harness the Power of JavaScript" by David Herman
-
Grunt JS: Quick Introduction by Tech CBT
-
Gulp JS: Quick Introduction (in 30 min) by Tech CBT
-
How to Install Gulp.js on Windows by Ollie Mc Farlane
-
gulp-concat by Eric Schoffstall