obfuscate css file by javascript obfuscation [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
If one have done some hard work and do not want anyone else to copy it, for example javascript, css, html. Is there a way?
I heard javascript can be obfuscated ( reffering to How can I obfuscate (protect) JavaScript? ) .
Theres no point in doing that for just html as SEO (search engine optimization ) would be effected.
How to do that for .css files though? Its very important for me.
What are the ways to make it harder? (other than just renaming variables/styles to bogus ones)
is there a way to include all the css and html into a javascript and then obfuscate the javascript?
Thank You.

The browser's built-in CSS debugger will show the RENDERED CSS, regardless of what sort of obfuscation madness you want to apply.
No point in doing it at all.
Or as I say: If you don't want it stolen, don't put it online.

You can parse/regex your outbound html with your external css files to make all your html have inline css, so nobody knows what classes you use.
Edit, yes, this is horribly and ridiculously inefficient, but it does prevent people from copy/pasting your valuable css files.

JavaScript can be obfuscated by using nonsensical variable and functions names and removing all formatting.
In CSS, the only thing you have control over is id names, class names and formatting. These are things that can easily be ignored or fixed, so there many other ways to obfuscate.

Related

Where to put css and javascript [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
If I understand Google encourages to put the css and javascript in the same page that the html. Internal css but not inline. On the other side, all the manuals and tutorials I have read say that I should use an external document.
Where should I put the css and javascript?
Note: in the design o my page there it makes no difference to use the css and javascript of the "above the folder" internal and the rest external. 90% or more of the css and javascript is for the content above the folder. In my case, it makes no sense make a distinction.
https://developers.google.com/speed/pagespeed/insights/
Resources are blocking the first paint of your page. Consider delivering critical JS/CSS inline and deferring all non-critical JS/styles
https://developers.google.com/web/tools/lighthouse/audits/critical-request-chains
There is marginal performance improvement in combining html, css, and javascript in a single document. This theoretical performance boost is outweighed by the many complicating factors that come from trying to do this. You might be saving 20-40ms by combining documents, which is generally not something the end user can detect. You will find more important performance improvements in many other ways.
Merging documents, when done at all, should be acccomplished by using a server-side assembly process so that your code can be well partitioned and well maintained. An example of this is webpack.
But again, unless there is some specialized use case that makes this important, it is not standard practice.

How to structure the JS? Put the code in a unique file or require the necessary JS code in the file where its used? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Do you know if is better to have a unique file with all JS or is better in each file require the specific JS that is necessary for that specific page?
The project sould stay better structured requiring the JS specific for each file.
But in terms of performance do you know if is basically the same or not?
For a small JS snippets is always better to implement it only on pages you need.
But, for big classes, framework or huge functions is better use single file with an CDN. That way is better performance and finaly better to maitenance and for developing is better to stay organized.
As second, in single file you can easily do minified version fully automated.
I prefer creating a unique JavaScript file and then linking it to the html file. It is the most efficient and organized way of structuring your code. But if the amount of code is very small and only required for that single page, inline JavaScript is preferred.
Performance: External JavaScript is always faster because the browser can cache an external file but Inline JavaScript will always be loaded afresh and hence is slower.

Drawbacks of including CSS and Javascript in HAML [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I need to change the design of various pages of a website developed in Ruby on Rails. I was thinking of modifying the HAML files to include CSS and Javascript to make the desining nicer and more responsive.
What could be the drawbacks of such an approach? I have came across such example here.
The drawbacks are exactly the same well known drawbacks of including anything but content in HTML.
Your muddling content with presentation and behavior. This leads down quick path to a total mess of inline everything and generally poor development practices.
Your CSS and JS will not leverage caching properly between pages that might otherwise share components.
Your CSS and JS will not be properly minified.
You will not be able to use code quality tools properly on CSS or JS.
The execution order of your JS is going to be confusing.
Your code indentation and quality in general will suck. This especially applies to HAML.
Other developers will hate you.
Rails even generates per controller stylesheets and scripts by default to make separating views from assets easier.
But in general the idiom of "per page" styles and behavior should be avoided unless you are creating trivial brocureware, you get better code quality and reuse if you try to envision a set of reusable parts or modules - HTML class attibutes are cheap - parsing a huge document with a junk drawer of CSS/JS is expensive.

Is it bad practice to include javascript files in Joomla articles? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I was going to wait until the StackExchange for Joomla was approved before asking this question, but I'd really like to know the answer now!
According to http://docs.joomla.org/Adding_JavaScript there are 3 methods for incorporating javascript into Joomla using-
JDocument::addScriptDeclaration, JDocument::addScript and script.
I believe there is a fourth way which is perhaps easier than the methods listed and that is to include the javascript into the article directly. For example, in a Joomla article I could use the following line <script src="/javascript/jquery-1.7.min.js"></script>
Since this method isn't listed in the docs, I'm thinking it must be bad practice.
QUESTIONs
Is it bad practice to include javascript files directly into Joomla
via an article? If so, why?
What reasons (if any) are there for me to choose the first 3 methods
as opposed to the 4th? (I'm particularly interested to know if the 4th
method would affect cache or cause problems when using cdns.)
Including JS in an article is a bad idea because of loading order and dependencies.
Only do that if you need the script only on that single article page and if you've tested its behavior (and if you are no coder).
Best way to do it is via:
JHtml::_('script', 'path_to_script/script.js', false, true);
If you want to embed it right and not fiddle with PHP you could use something like this:
http://extensions.joomla.org/extensions/core-enhancements/performance/scripts/20245
If you need the script only on that one page, then it's better to add it in the article itself.
You can't use JDocument::addScriptDeclaration, JDocument::addScript because these are PHP functions. Unless your editor allows you to add PHP, then you can't use them.
The 4th option is the best.
The true answer lies in what you are trying to do with your script. There are many uses for Java script in articles, such as syndicated features or affiliate marketing.
TinyMCE limits some of the things you can use your articles for so I use JCE Content Editor for more power and options. There are free versions as well as pro versions available.
Check it out here: http://www.joomlacontenteditor.net/

Is there a guide about how to create beautiful HTML that is preped to be used with javascript? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
This might seem like an odd question, but I find that javascript is either easy or hard, depending on how you've coded the HTML. Is there a book or website that goes into detail about successful patterns and guidelines for coding HTML, so that it's very workable with jQuery, css and complex ajax applications? Like solid rules to live by.
Again, seems like a weird question maybe, but I don't know a better way to ask it. I just find myself always having to change the markup as new things come up - like switching between a hidden input element to a data attribute... or putting more ids or taking away ids - and I guess I arrive at the right way to do it, but I'm curious if someone has bothered to analyze this and came up with some great guidelines, standards and patterns so that the resultant HTML is right the first time.
Thanks
The first thing if you want to code some clean HTML that will be easy to work with is to make sure that your code is valid against an official DTD, HTML4 (here) or XHTML (here).
Then use id and class in a proper way (id only for unique section and class for repeatable ones) and name them correctly according to the context so they are easily reachable.
From my experience, I would actually suggest that, when it comes to large projects and professional JavaScript coding, the goal actually becomes to decouple the JavaScript code from whatever HTML it lives in.
As mentioned already, as long as you are using well formed HTML (DTD compliant), a library like jQuery shouldn't have any trouble operating on it. However, as best practice, I would recommend striving to isolate and encapsulate dependencies, whether they be because of HTML structure or just other chunks of JavaScript code.
the best way is to develop the html and javascript together. That way you can adjust the document structure to whatever you need.
This article seems to answer my question:
http://www.viget.com/inspire/extending-paul-irishs-comprehensive-dom-ready-execution/

Categories

Resources