Title: JS error with code written without ;
Last modified: February 20, 2017

---

# JS error with code written without ;

 *  Resolved [shaolinshaosson](https://wordpress.org/support/users/shaolinshaosson/)
 * (@shaolinshaosson)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/js-error-with-code-written-without/)
 * Anyone else has problems if js-files included in theme/plugins is written without
   using semicolons fully?
 * Like with this code for example:
 *     ```
       (function(factory) {
   
         if (typeof exports == 'object') {
           // CommonJS
           factory(require('jquery'), require('spin'))
         }
         else if (typeof define == 'function' && define.amd) {
           // AMD, register as anonymous module
           define(['jquery', 'spin'], factory)
         }
         else {
           // Browser globals
           if (!window.Spinner) throw new Error('Spin.js not present')
           factory(window.jQuery, window.Spinner)
         }
   
       }(function($, Spinner) {
   
         $.fn.spin = function(opts, color) {
   
           return this.each(function() {
             var $this = $(this),
               data = $this.data();
   
             if (data.spinner) {
               data.spinner.stop();
               delete data.spinner;
             }
             if (opts !== false) {
               opts = $.extend(
                 { color: color || $this.css('color') },
                 $.fn.spin.presets[opts] || opts
               )
               data.spinner = new Spinner(opts).spin(this)
             }
           })
         }
   
         $.fn.spin.presets = {
           tiny: { lines: 8, length: 2, width: 2, radius: 3 },
           small: { lines: 8, length: 4, width: 3, radius: 5 },
           large: { lines: 10, length: 8, width: 4, radius: 8 }
         }
   
       }));
       ```
   
 * Since it minifies:
 *     ```
       if (!window.Spinner) throw new Error('Spin.js not present')
           factory(window.jQuery, window.Spinner)
       ```
   
 * to:
 *     ```
       if (!window.Spinner) throw new Error('Spin.js not present') factory(window.jQuery, window.Spinner)
       ```
   
 * I get ‘SyntaxError: missing ; before statement’ that makes this plugin unusable.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Philip K Meadows](https://wordpress.org/support/users/philmeadows/)
 * (@philmeadows)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/js-error-with-code-written-without/#post-8837316)
 * There’s three options to get around this:
    1. Terminate your javascript command lines correctly with semicolons;
    2. Use a pre-minified version of the javascript, if one is available
    3. Or, rename the javascript file to contain the string `min` in the file name –
       WP Roids should then ignore minifying it
 * Phil
 *  Plugin Author [Philip K Meadows](https://wordpress.org/support/users/philmeadows/)
 * (@philmeadows)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/js-error-with-code-written-without/#post-8837336)
 * Also, wrap statements in curly braces `{}`
 * Your code above should be:
 *     ```
       if(!window.Spinner) {
           throw new Error('Spin.js not present');
           factory(window.jQuery,window.Spinner);
       }
       ```
   
    -  This reply was modified 9 years, 3 months ago by [Philip K Meadows](https://wordpress.org/support/users/philmeadows/).
 *  Thread Starter [shaolinshaosson](https://wordpress.org/support/users/shaolinshaosson/)
 * (@shaolinshaosson)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/js-error-with-code-written-without/#post-8838414)
 * The problem is that the lack of semicolons exist in a lot of different plugins
   resources, so I would need to dig deep in all those js files and find out which
   ones are written that way, and either unload the included file and replace with
   pre-minified version, or unload the file and add “.min” tot he filename in my
   own version = pain in the ass when updating plugins.
    I was hoping that there
   would be a better way since others must also have this problem, I know it’s the
   plugins creators that should have used a pre-min version of its resources or 
   take into account that people might want to minfy/combine all files. Would be
   nice if there would be a feature to setup what files should be minified or ignored
   for your plugin.
 *  Plugin Author [Philip K Meadows](https://wordpress.org/support/users/philmeadows/)
 * (@philmeadows)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/js-error-with-code-written-without/#post-8874728)
 * That’s not a bad idea
 * I’ll work on an option(s) to disable minification on a per plugin basis
 * Would be handy for debugging!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘JS error with code written without ;’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-roids_626262.svg)
 * [WP Roids](https://wordpress.org/plugins/wp-roids/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-roids/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-roids/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-roids/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-roids/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-roids/reviews/)

## Tags

 * [syntax error](https://wordpress.org/support/topic-tag/syntax-error/)

 * 4 replies
 * 2 participants
 * Last reply from: [Philip K Meadows](https://wordpress.org/support/users/philmeadows/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/js-error-with-code-written-without/#post-8874728)
 * Status: resolved