bevacqua / insane

:pouting_cat: Lean and configurable whitelist-oriented HTML sanitizer
https://ponyfoo.com
MIT License
449 stars 22 forks source link

wish: docs for using in the browser. #3

Closed markstos closed 8 years ago

markstos commented 8 years ago

It would be helpful if the docs explained the recommended way to load this module and it's dependencies for use in a browser.

bevacqua commented 8 years ago

Out of scope, but you can use browserify, webpack, or a similar bundling tool

markstos commented 8 years ago

I don't think documenting a feature that you claim to have-- browser support-- is out of scope for a high quality module. While code should by DRY, documentation often benefits from being repeated to some degree in multiple places where it's useful.

Honestly, I tried with browserify, read some docs, tried some things and it didn't work.

This intro to browserify is typical of docs for Browserify that are found. It boils down to:

browserify js/some-file.js -o js/bundle.js

And then

From there, it’s as simple as including the file on your page like any other JS file:

  <script src="js/bundle.js"></script>

Well, if you browserify on insane.js and create a bundle and load it in a script tag like that, nothing happens. insane is not exported, require is not exported.

Perhaps the idea is that my entire app is turned into a giant Browserify bundle, but that won't work in this case: I just want to use the insane function the browser and it should be easy to do.

If just a couple lines of code are required, that it seems like an easy improvement to the docs. If it's an involved process, that that definitely seems worth documenting or at least referencing docs that cover the topic.

markstos commented 8 years ago

According to this site, the insane module is not detected as one that is "browerifyable": http://browserifysearch.org/search?q=insane

bevacqua commented 8 years ago

@markstos insane is a library, not supposed to be an entry point. If you want insane as a global, do browserify -s insane insane.js, where -s insane means "standalone" and "name it window.insane".

markstos commented 8 years ago

Thanks for the tip!