Skip to content
Akin C edited this page Apr 15, 2018 · 14 revisions

Welcome to the Javascript-concatenating-strict-files- wiki!

This repository is part of a larger project!

◀️ PREVIOUS PROJECT| NEXT 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.

Initial condition

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:

  1. Grunt JS: Quick Introduction
  2. Gulp JS: Quick Introduction (in 30 min)

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.

"example1"

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.

"example2"

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.

Solution

There are two solutions for this kind of problem

  1. Avoid concatenating strict with nonstrict files and vice versa
  2. Wrap the body of the concatenating files - Project
Clone this wiki locally