html-prefix

0.1.1 • Public • Published

Html prefix

Prefix html template url from selected tags.

Install

npm install html-prefix

Usage

var prefix = require('html-prefix');
var html = '<script src="/js/example.js"></script>';
var prefixUrl = '//example.com/';
 
var newHtml = prefix(html, {
    prefix: prefixUrl
});
 
console.log(newHtml); //=> <script src="//example.com//js/example.js"></script>

otions

prefix: Url prefix path.
attrs: Set the selector to prefix path.
You can set a object, like so:

```javascript
{  
    'link:href': false, // to cancel the selector  
    'img:data-href': true // to add the selector  
}
```

You can set a array, like so:  

```javascript
['img:data-href',...] // to add any selector
```

default selector have "img:src", "img:srcset", "img:data-src", "script:src", "link:href"

Readme

Keywords

Package Sidebar

Install

npm i html-prefix

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • idler_z