marcuswestin / store.js

Cross-browser storage for all use cases, used across the web.
MIT License
14.01k stars 1.33k forks source link

Struggling with basic usage in a HTML page #238

Closed mushfek closed 7 years ago

mushfek commented 7 years ago

Hi,

I'm trying to use store.js as a simple frontend cache in a HTML using the But I've got Uncaught ReferenceError: require is not defined. Then I've added require.js 2.3.3 using the script tag as well before store.legacy.min.js but now getting this instead Uncaught Error: Module name "store" has not been loaded yet for context: _. Use require([])http://requirejs.org/docs/errors.html#notloaded at makeError (require-2.3.3.js:168) at Object.localRequire [as require] (require-2.3.3.js:1436) at requirejs (require-2.3.3.js:1797) at home.html:10 I am new to JavaScript so can someone please explain what am I doing wrong? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub , or mute the thread .

marcuswestin commented 7 years ago

(and remove require.js)

mushfek commented 7 years ago

Thanks for the fast response. Could you please help me a little more? If I use store by default it uses localStorage but how can I use other plugins? I mean I only want to use memoryStorage. How can I configure storage to do that?

marcuswestin commented 7 years ago

Sure :)

If you want to make a custom build you'll need to be using a js package/module system instead of a script tag. If you're very new to js development then this may take you a bit of effort to get set up, but it's the best way to make it happen and you'll definitely want to learn this sooner or later anyway. I recommend webpack - Google it (or any of its alternatives) for tutorials.

Once you have that up and running your just follow the instructions here: https://github.com/marcuswestin/store.js/blob/master/README.md#user-content-make-your-own-build .

One alternative is to clone this repo and compile your own custom build, then use that in a script tag. I may add instructions for that later.

Best of luck! On Wed, Jun 21, 2017 at 2:28 AM Mushfekur Rahman notifications@github.com wrote:

Thanks for the fast response. Could you please help me a little more? If I use store by default it uses localStorage but how can I use other plugins? I mean I only want to use memoryStorage. How can I configure storage to do that?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/marcuswestin/store.js/issues/238#issuecomment-309976402, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIDf4C7b9HraJGTPOSzVS8FVhHpAdGLks5sGLgYgaJpZM4N_EWt .

alrick commented 7 years ago

Hey there!

Maybe you should update the README accordingly or am I missing something?

marcuswestin commented 7 years ago

If you update the readme and create a pull request I'll merge it in :) On Thu, Jul 27, 2017 at 7:43 AM Alrick Deillon notifications@github.com wrote:

Hey there!

Maybe you should update the README accordingly or am I missing something?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/marcuswestin/store.js/issues/238#issuecomment-318338551, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIDf66G7d49iYS-VS3JUJaU8eVweEZAks5sSHfugaJpZM4N_EWt .

alrick commented 7 years ago

246

Here you go ;)