SOW : Core Plugins

SOW = Step Of Web (Smarty author).
SOW plugins are part of Smarty Core, written from scratch!

Usual stuff, your website will work without internet connection!

Wait! What?

For sure you already know about Service Workers from your Developer Console - is that greyish icon "PWA" (Progressive Web Apps) in Google Chrome Audits and you get extra points if your site is capable of being available offline.

Not much (to make a huge case from this), but it does matter a little bit for SEO because Google care about your users/visitors (not really because your website is faster than speed of light). Service Workers are able to give you some kind of "super powers" - is a very strong cache for your website and is able to serve from cache even if the internet connection goes down.

Smarty include all you need to activate it in seconds and forget about paying your internet connection.
The `brain` of all this is that little js file called "sw.js" you might already noticed it (or you might will) in your project folder. If you are a begginer, might look a little bit scary but it's not! `Smarty` lost hours to test/retest, write/rewrite throwing PC's out of the window and all this cool stuff to work for you in seconds! If you changed the assets folder location, you have to edit that file to set the new location. After that, activate the Controller from gulp.config__core.js. And that's it!

Please, note!
The good: will increase a lot the site speed because of a very strong cache.
The "bad": if you are a developer, even if you deactivate it, the cache is sometimes still there without noticing it, even using an icognito window, it's like cockroaches!

So please keep this in mind when you test it, as a developer. Or when your customer test it (uh!)!
Better approach: don't let your customer to test with SW active! Surprise your customer at the end!

To stop the worker, open your browser console (assuming you are using Google Chrome) -> Application -> Service Workers. Unregister and stop it! And of course, hard refresh your browser. Smarty Debugger will show you in the console if the Service Worker is still active!

Additional note: a valid SSL certificate is required (localhost self signed are also working)!
https://developers.google.com/web/ilt/pwa/introduction-to-service-worker
https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Offline_Service_workers


1. Edit sw.js
  * Open sw.js file from your document root
  * Edit in cacheFiles: the homepage (default is index.html) and the assets paths (if changed)
  * Save


2. Activate Smarty Controller
  * Open gulp.config__core.js
  * Enable Smarty Service Worker Controller
    sow_service_worker: { enable: true, autoinit: true, bundle: true }
-----
  * Rebuild the project using GULP
  * Thats it!


-----
Note: sw.js cannot be moved from document root!
-----


/* 
     :: SOW Controller
     src/js/sow.core/sow.service_worker.js
*/