Understrap: Custom JS

Created on 10 Feb 2018  路  5Comments  路  Source: understrap/understrap

I can't get the adding of custom JS done.

Could you enumerate how to get this right?

What I did was:

  1. Copy custom JS in any folder inside understrap folder.
  2. Inside gulpscript.js file, add basePaths.dev + 'js/mycustomjs.js' then run gulpscripts
Duplicate Enhancement Needs investigation Seems fixed URGENT!

Most helpful comment

To avoid confusion:

  1. Add file 'custom.js' to /src/js/
  2. Add this after line 186 of gulp.js
    paths.dev + '/js/custom.js'
  3. Make sure to add a comma after the previous line:
    paths.dev + '/js/skip-link-focus-fix.js',

Complete code will look like this:

    var scripts = [

        // Start - All BS4 stuff
        paths.dev + '/js/bootstrap4/bootstrap.js',

        // End - All BS4 stuff

        paths.dev + '/js/skip-link-focus-fix.js',
        paths.dev + '/js/custom.js'
    ];

All 5 comments

Are you using the child theme set-up? If so, custom JS can be added to line 112 of the child's gulp file:

gulp.watch([basePaths.dev + 'js//.js','js//.js','!js/child-theme.js','!js/child-theme.min.js'], ['scripts']);

https://github.com/holger1411/understrap-child/blob/master/gulpfile.js

No, I'm using Parent Theme.

if you look at .gulpconfig.json you can see that basePaths.dev is ./src so your js file needs to live in /src/js/

To avoid confusion:

  1. Add file 'custom.js' to /src/js/
  2. Add this after line 186 of gulp.js
    paths.dev + '/js/custom.js'
  3. Make sure to add a comma after the previous line:
    paths.dev + '/js/skip-link-focus-fix.js',

Complete code will look like this:

    var scripts = [

        // Start - All BS4 stuff
        paths.dev + '/js/bootstrap4/bootstrap.js',

        // End - All BS4 stuff

        paths.dev + '/js/skip-link-focus-fix.js',
        paths.dev + '/js/custom.js'
    ];

Thanks for your contributions, @ZacharyElkins and @jsgaonac . As requests upon this feature are adding up recently, I just pushed a commit that麓s based on your proposal, @ZacharyElkins .

Please investigate if it works like intended. It does so on my dev-environtment, though.

See #593 and #602 as duplicates.

Closing this issue as it should be finally resolved now. Feel free to re-open if the problem persists, okay?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Routhinator picture Routhinator  路  3Comments

jsgaonac picture jsgaonac  路  5Comments

kmob2 picture kmob2  路  4Comments

ZacharyElkins picture ZacharyElkins  路  3Comments

blachawk picture blachawk  路  5Comments