php get DOM
remove script tags
https://stackoverflow.com/questions/7130867/remove-script-tag-from-html-content/7131085
美剧网 《爱,死亡和机器人 第一季》
https://91mjw.com/video/1295.htm
压缩 css
uglifycss –convert-urls test lib/font-awesome-4.7.0/css/font-awesome.min.css lib/ionicons-2.0.0/css/ionicons.min.css lib/mwa/mwa.css lib/animation.min.css \
css/ok.css
插件兼容AMD, CMD ,CommonJS和 原生 JS
1 | ;(function(){ |
1 | if (typeof module != 'undefined' && module.exports) { //CMD |
1 | var root = (typeof self == 'object' && self.self == self && self) || |
via
array remove duplicated item
const arr = [22,33,22,44,22];
// 1
[…new Set(arr)];
// 2
arr.filter((k,j)=>arr.indexOf(k)=== j)
// 3
arr.reduce((tt,k)=>{
console.log(tt,k)
return tt.includes(k) ? tt: […tt,k]
},[])
via
https://medium.com/dailyjs/how-to-remove-array-duplicates-in-es6-5daa8789641c
uglifyjs 默认只能 es5
https://www.npmjs.com/package/uglify-es
需要安装
npm install uglify-es -g
uglifyjs gsmap.js -m -o gsmap.min.js
uglifyjs js/file1.js js/file2.js
-o foo.min.js -c -m
–source-map “root=’http://foo.com/src',url='foo.min.js.map'"
uglifyjs ../lib/axios.min.js gsmap.js
-c drop_console -m -o gsmap.min.js
压缩项目
uglifyjs main.js app.js pos.js
-c drop_console -m -o gs.min.js
let a = Array(14).fill().map((k,j)=>j+1);
a.reduce((tt,k)=>{
return tt+’curl https://i.jd.com/defaultImgs/'+k+'.jpg -o ‘+k+’.jpg\n’;
},’’)
n ES6 using Array from() and keys() methods.
Array.from(Array(10).keys())
//=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Shorter version using spread operator.
[…Array(10).keys()]
//=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
babel
https://blog.zfanw.com/babel-js/#babelcli
1231231314
abc
https://blog.zfanw.com/babel-js/#babel-套餐
const alertMe = (msg) => {
window.alert(msg)
}
class Robot {
constructor (msg) {
this.message = msg
}
say () {
alertMe(this.message)
}
}
const marvin = new Robot(‘hello babel’)
firebase-hosting-static-site
https://blog.zfanw.com/firebase-hosting-static-site/
iOS Safari 点击事件失效
这是移动端 Safari 至今仍存在的一个 bug 特性。
有几个解决办法:
最简单的,给 CSS 加上 cursor: pointer;
停止委托,直接给 #btn 绑定事件处理器;
给 div 元素加上 onclick=’void(0);’;
将 div 换成其它不受该 bug 特性影响的元素,比如 a、button 等。
有效 json
A comment first. The question was about not using try/catch.
If you do not mind to use it, read the answer below. Here we just check a JSON string using a regexp, and it will work in most cases, not all cases.
Have a look around the line 450 in https://github.com/douglascrockford/JSON-js/blob/master/json2.js
There is a regexp that check for a valid JSON, something like:
1 | if (/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g, '@'). |
pan.baidu.com
mqtt
http://test.mosquitto.org/ws.html
http://louiszhai.github.io/2017/04/28/array/#keys-ES6
https://juejin.im/post/5d66b019f265da03a715e5d7
https://dev.to/saigowthamr/how-to-loop-through-object-in-javascript-es6-3d26