前端代码如何不开源?

大伯格
  • 371

前端代码怎么不开源?总是说开源开源。但是不懂前端的代码怎么做到不开源?比如react开源了是什么意思?react不开源是什么样子?。
审查元素html css js不就全都暴露在眼前了吗?怎么样才算不开源?

回复
阅读 4.2k
3 个回答
✓ 已被采纳

前端只有混淆这一种办法,即使混淆也可以查看,就是费劲而已。可以用webpack打包一下,阅读难度就增加了!



webpackJsonp([1,0],[,,function(t,e,n){"use strict";var i=n(86)["default"];e["default"]=function(t){return t&&t.constructor===i?"symbol":typeof t},e.__esModule=!0},,,function(t,e,n){(function(e){/*!
     * Vue.js v1.0.28
     * (c) 2016 Evan You
     * Released under the MIT License.
     */
"use strict";function n(t,e,i){if(r(t,e))return void(t[e]=i);if(t._isVue)return void n(t._data,e,i);var o=t.__ob__;if(!o)return void(t[e]=i);if(o.convert(e,i),o.dep.notify(),o.vms)for(var s=o.vms.length;s--;){var a=o.vms[s];a._proxy(e),a._digest()}return i}function i(t,e){if(r(t,e)){delete t[e];var n=t.__ob__;if(!n)return void(t._isVue&&(delete t._data[e],t._digest()));if(n.dep.notify(),n.vms)for(var i=n.vms.length;i--;){var o=n.vms[i];o._unproxy(e),o._digest()}}}function r(t,e){return Wn.call(t,e)}function o(t){return Jn.test(t)}function s(t){var e=(t+"").charCodeAt(0);return 36===e||95===e}function a(t){return null==t?"":t.toString()}function c(t){if("string"!=typeof t)return t;var e=Number(t);return isNaN(e)?t:e}function u(t){return"true"===t||"false"!==t&&t}function l(t){var e=t.charCodeAt(0),n=t.charCodeAt(t.length-1);return e!==n||34!==e&&39!==e?t:t.slice(1,-1)}function h(t){return t.replace(zn,f)}function f(t,e){return e?e.toUpperCase():""}function p(t){return t.replace(Gn,"$1-$2").replace(Gn,"$1-$2").toLowerCase()}function d(t){return t.replace(Un,f)}function v(t,e){return function(n){var i=arguments.length;return i?i>1?t.apply(e,arguments):t.call(e,n):t.call(e)}}function g(t,e){e=e||0;for(var n=t.length-e,i=new Array(n);n--;)i[n]=t[n+e];return i}function m(t,e){for(var n=Object.keys(e),i=n.length;i--;)t[n[i]]=e[n[i]];return t}function y(t){return null!==t&&"object"==typeof t}function b(t){return Yn.call(t)===qn}function _(t,e,n,i){Object.defineProperty(t,e,{value:n,enumerable:!!i,writable:!0,configurable:!0})}function w(t,e){var n,i,r,o,s,a=function c(){var a=Date.now()-o;a<e&&a>=0?n=setTimeout(c,e-a):(n=null,s=t.apply(r,i),n||(r=i=null))};return function(){return r=this,i=arguments,o=Date.now(),n||(n=setTimeout(a,e)),s}}function A(t,e){for(var n=t.length;n--;)if(t[n]===e)return n;return-1}function x(t){var e=function n(){if(!n.cancelled)return t.apply(this,arguments)};return e.cancel=function(){e.cancelled=!0},e}function C(t,e){return t==e||!(!y(t)||!y(e))&&JSON.stringify(t)===JSON.stringify(e)}function k(t){return/native code/.test(t.toString())}function S(t){this.size=0,this.limit=t,this.head=this.tail=void 0,this._keymap=Object.create(null)}function O(){return di.charCodeAt(mi+1)}function E(){return di.charCodeAt(++mi)}function I(){return mi>=gi}function $(){for(;O()===$i;)E()}function j(t){return t===Si||t===Oi}function N(t){return ji[t]}function T(t,e){return Ni[t]===e}function D(){for(var t,e=E();!I();)if(t=E(),t===Ii)E();else if(t===e)break}function B(t){for(var e=0,n=t;!I();)if(t=O(),j(t))D();else if(n===t&&e++,T(n,t)&&e--,E(),0===e)break}function M(){for(var t=mi;!I();)if(yi=O(),j(yi))D();else if(N(yi))B(yi);else if(yi===Ei){if(E(),yi=O(),yi!==Ei){bi!==Ai&&bi!==ki||(bi=xi);break}E()}else{if(yi===$i&&(bi===Ci||bi===ki)){$();break}bi===xi&&(bi=Ci),E()}return di.slice(t+1,mi)||null}function F(){for(var t=[];!I();)t.push(R());return t}function R(){var t,e={};return bi=xi,e.name=M().trim(),bi=ki,t=P(),t.length&&(e.args=t),e}function P(){for(var t=[];!I()&&bi!==xi;){var e=M();if(!e)break;t.push(L(e))}return t}function L(t){if(wi.test(t))return{value:c(t),dynamic:!1};var e=l(t),n=e===t;return{value:n?t:e,dynamic:n}}function Q(t){var e=_i.get(t);if(e)return e;di=t,vi={},gi=di.length,mi=-1,yi="",bi=Ai;var n;return di.indexOf("|")<0?vi.expression=di.trim():(vi.expression=M().trim(),n=F(),n.length&&(vi.filters=n)),_i.put(t,vi),vi}function H(t){return t.replace(Di,"\\$&")}function W(){var t=H(Hi.delimiters[0]),e=H(Hi.delimiters[1]),n=H(Hi.unsafeDelimiters[0]),i=H(Hi.unsafeDelimiters[1]);Mi=new RegExp(n+"((?:.|\\n)+?)"+i+"|"+t+"((?:.|\\n)+?)"+e,"g"),Fi=new RegExp("^"+n+"((?:.|\\n)+?)"+i+"$"),Bi=new S(1e3)}function J(t){Bi||W();var e=Bi.get(t);if(e)return e;if(!Mi.test(t))return null;for(var n,i,r,o,s,a,c=[],u=Mi.lastIndex=0;n=Mi.exec(t);)i=n.index,i>u&&c.push({value:t.slice(u,i)}),r=Fi.test(n[0]),o=r?n[1]:n[2],s=o.charCodeAt(0),a=42===s,o=a?o.slice(1):o,c.push({tag:!0,value:o.trim(),html:r,oneTime:a}),u=i+n[0].length;return u<t.length&&c.push({value:t.slice(u)}),Bi.put(t,c),c}function z(t,e){return t.length>1?t.map(function(t){return G(t,e)}).join("+"):G(t[0],e,!0)}function G(t,e,n){return t.tag?t.oneTime&&e?'"'+e.$eval(t.value)+'"':U(t.value,n):'"'+t.value+'"'}function U(t,e){if(Ri.test(t)){var n=Q(t);return n.filters?"this._applyFilters("+n.expression+",null,"+JSON.stringify(n.filters)+",false)":"("+t+")"}return e?t:"("+t+")"}function Y(t,e,n,i){K(t,1,function(){e.appendChild(t)},n,i)}function q(t,e,n,i){K(t,1,function(){it(t,e)},n,i)}function V(t,e,n){K(t,-1,function(){ot(t)},e,n)}function K(t,e,n,i,r){var o=t.__v_trans;if(!o||!o.hooks&&!si||!i._isCompiled||i.$parent&&!i.$parent._isCompiled)return n(),void(r&&r());var s=e>0?"enter":"leave";o[s](n,r)}function X(t){if("string"==typeof t){t=document.querySelector(t)}return t}function Z(t){if(!t)return!1;var e=t.ownerDocument.documentElement,n=t.parentNode;return e===t||e===n||!(!n||1!==n.nodeType||!e.contains(n))}function tt(t,e){var n=t.getAttribute(e);return null!==n&&t.removeAttribute(e),n}function et(t,e){var n=tt(t,":"+e);return null===n&&(n=tt(t,"v-bind:"+e)),n}function nt(t,e){return t.hasAttribute(e)||t.hasAttribute(":"+e)||t.hasAttribute("v-bind:"+e)}function it(t,e){e.parentNode.insertBefore(t,e)}function rt(t,e){e.nextSibling?it(t,e.nextSibling):e.parentNode.appendChild(t)}function ot(t){t.parentNode.removeChild(t)}function st(t,e){e.firstChild?it(t,e.firstChild):e.appendChild(t)}function at(t,e){var n=t.parentNode;n&&n.replaceChild(e,t)}function ct(t,e,n,i){t.addEventListener(e,n,i)}function ut(t,e,n){t.removeEventListener(e,n)}function lt(t){var e=t.className;return"object"==typeof e&&(e=e.baseVal||""),e}function ht(t,e){ni&&!/svg$/.test(t.namespaceURI)?t.className=e:t.setAttribute("class",e)}function ft(t,e){if(t.classList)t.classList.add(e);else{var n=" "+lt(t)+" ";n.indexOf(" "+e+" ")<0&&ht(t,(n+e).trim())}}function pt(t,e){if(t.classList)t.classList.remove(e);else{for(var n=" "+lt(t)+" ",i=" "+e+" ";n.indexOf(i)>=0;)n=n.replace(i," ");ht(t,n.trim())}t.className||t.removeAttribute("class")}function dt(t,e){var n,i;if(mt(t)&&At(t.content)&&(t=t.content),t.hasChildNodes())for(vt(t),i=e?document.createDocumentFragment():document.createElement("div");n=t.firstChild;)i.appendChild(n);return i}function vt(t){for(var e;e=t.firstChild,gt(e);)t.removeChild(e);for(;e=t.lastChild,gt(e);)t.removeChild(e)}function gt(t){return t&&(3===t.nodeType&&!t.data.trim()||8===t.nodeType)}function mt(t){return t.tagName&&"template"===t.tagName.toLowerCase()}function yt(t,e){var n=Hi.debug?document.createComment(t):document.createTextNode(e?" ":"");return n.__v_anchor=!0,n}function bt(t){if(t.hasAttributes())for(var e=t.attributes,n=0,i=e.length;n<i;n++){var r=e[n].name;if(zi.test(r))return h(r.replace(zi,""))}}function _t(t,e,n){for(var i;t!==e;)i=t.nextSibling,n(t),t=i;n(e)}function wt(t,e,n,i,r){function o(){if(a++,s&&a>=c.length){for(var t=0;t<c.length;t++)i.appendChild(c[t]);r&&r()}}var s=!1,a=0,c=[];_t(t,e,function(t){t===e&&(s=!0),c.push(t),V(t,n,o)})}function At(t){return t&&11===t.nodeType}function xt(t){if(t.outerHTML)return t.outerHTML;var e=document.createElement("div");return e.appendChild(t.cloneNode(!0)),e.innerHTML}function Ct(t,e){var n=t.tagName.toLowerCase(),i=t.hasAttributes();if(Gi.test(n)||Ui.test(n)){if(i)return kt(t,e)}else{if(Nt(e,"components",n))return{id:n};var r=i&&kt(t,e);if(r)return r}}function kt(t,e){var n=t.getAttribute("is");if(null!=n){if(Nt(e,"components",n))return t.removeAttribute("is"),{id:n}}else if(n=et(t,"is"),null!=n)return{id:n,dynamic:!0}}function St(t,e){var i,o,s;for(i in e)o=t[i],s=e[i],r(t,i)?y(o)&&y(s)&&St(o,s):n(t,i,s);return t}function Ot(t,e){var n=Object.create(t||null);return e?m(n,$t(e)):n}function Et(t){if(t.components)for(var e,n=t.components=$t(t.components),i=Object.keys(n),r=0,o=i.length;r<o;r++){var s=i[r];Gi.test(s)||Ui.test(s)||(e=n[s],b(e)&&(n[s]=Fn.extend(e)))}}function It(t){var e,n,i=t.props;if(Vn(i))for(t.props={},e=i.length;e--;)n=i[e],"string"==typeof n?t.props[n]=null:n.name&&(t.props[n.name]=n);else if(b(i)){var r=Object.keys(i);for(e=r.length;e--;)n=i[r[e]],"function"==typeof n&&(i[r[e]]={type:n})}}function $t(t){if(Vn(t)){for(var e,n={},i=t.length;i--;){e=t[i];var r="function"==typeof e?e.options&&e.options.name||e.id:e.name||e.id;r&&(n[r]=e)}return n}return t}function jt(t,e,n){function i(i){var r=Yi[i]||qi;s[i]=r(t[i],e[i],n,i)}Et(e),It(e);var o,s={};if(e["extends"]&&(t="function"==typeof e["extends"]?jt(t,e["extends"].options,n):jt(t,e["extends"],n)),e.mixins)for(var a=0,c=e.mixins.length;a<c;a++){var u=e.mixins[a],l=u.prototype instanceof Fn?u.options:u;t=jt(t,l,n)}for(o in t)i(o);for(o in e)r(t,o)||i(o);return s}function Nt(t,e,n,i){if("string"==typeof n){var r,o=t[e],s=o[n]||o[r=h(n)]||o[r.charAt(0).toUpperCase()+r.slice(1)];return s}}function Tt(){this.id=Vi++,this.subs=[]}function Dt(t){tr=!1,t(),tr=!0}function Bt(t){if(this.value=t,this.dep=new Tt,_(t,"__ob__",this),Vn(t)){var e=Kn?Mt:Ft;e(t,Xi,Zi),this.observeArray(t)}else this.walk(t)}function Mt(t,e){t.__proto__=e}function Ft(t,e,n){for(var i=0,r=n.length;i<r;i++){var o=n[i];_(t,o,e[o])}}function Rt(t,e){if(t&&"object"==typeof t){var n;return r(t,"__ob__")&&t.__ob__ instanceof Bt?n=t.__ob__:tr&&(Vn(t)||b(t))&&Object.isExtensible(t)&&!t._isVue&&(n=new Bt(t)),n&&e&&n.addVm(e),n}}function Pt(t,e,n){var i=new Tt,r=Object.getOwnPropertyDescriptor(t,e);

代码混淆压缩吧

不开源是压缩过的,很多js变量都变成 a,b,c,d,e等不可读的变量,这种就是不开源,部分不开源的前端代码还进行了混淆加密。虽然你能直接看到这些代码,但是你修改起来很困难

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏