Can someone give me pointers on how I can minify and combine my CSS as the site I'm working on has performance issues. Also, are external JS and CSS libraries also minified and combined or left as is?
There are several convenient options for .NET, for example:
Chirpy
SquishIt
Cassette
And new in ASP.NET 4.5:
Bundling in ASP.NET 4.5
I'd recommend reading Google's Page Speed and their Closure Compiler Service.
I would also add RequestReduce for .net options. It may be the only runtime bundling option for minifying external resources. Its unique from the other .net options in that it grabs the unminified content via http instead of via the file system. It can also sprite your background images.
I know this is an old question but I thought I will give a better answer (trick).
In visual studio if you do format code (Ctrl + K + D) then css will be formatted nicely for you.
Related
Aside from some simple introductory tutorials and messing around with the default template, this is my first ever ASP.NET app and I'm a bit overwhelmed with all of the configurations, folders, features. I want to add the jquery terminal found here
https://terminal.jcubic.pl/
to one of my html pages, however the instructions on how to do that aren't very helpful. Where do I even unzip / install it once it's downloaded? And once that's in the right place, how do I reference it / include it in an html page? Does it need to go in a bundle? Any help would be much appreciated.
I have a batch of HTML files which need some editions easy to perform with jQuery (mainly selecting some nodes and changing their attributes).
My approach to achive this, has been opening them one by one in Google Chrome, excecuting the jQuery code in the console, and then copying the resulting DOM back to my HTML editor.
Since what I'm currently doing takes a lot of time, and also due to the fact that every file needs the same edition (i.e., the same jQuery/JS code will work for every HTML file), I am considering to write a script/program to do this.
Anyway, I am not completely clear of which of the following (if any of them) approaches I should take to accomplish this task.
Write a JavaScript script with jQuery using some FileSystem/File manipulation library (which one?)
Write a Java or C# program using some jQuery-based library (like CsQuery)
Finding a plugin for some of my editors (Aptana, Notepad++, Eclipse, etc) or a completely different editor that supports jQuery-like commands for edition (just as notepad++ regex replacement support). This would be slow with big batches, but at least it would allow me to avoid the annoying copy/paste to/from Chrome.
Is one of this approaches the right way to accomplish what I need? (Is there a right way to do this?) Which should be more straight-forward?
I think that #2 would be easier for me since I have a lot more experience in Java and C# than in JavaScript, but I think that maybe that idea would be sort of using a sledgehammer to crack a nut.
You should consider using PhantomJs. It is a headless WebKit which can be executed from te commandline. It accepts a javascript or coffeescript file as a an argument, which can be used to e.g. do something with a web page. Here is an example:
var page = require('webpage').create();
page.open('http://m.bing.com', function(status) {
var title = page.evaluate(function(s) {
return document.querySelector(s).innerText;
}, 'title');
console.log(title);
phantom.exit();
});
I am not sure of the right way but it sounds like you are familiar with C# and would think writing a class library would be the least overhead for automation. Here are some potential solutions:
Scripting Library (e.g., C#.NET) - You can use a library like the one you mentioned or something like ScriptSharp if you want to use DOM manipulation. If the HTML has appropriate closing tags you can also use LINQ to easily navigate the HTML (or something like the HTML Agility Pack found on CodePlex). I would even recommend using Mustache with an HTML file template in C#.
JavaScript Library - If you wanted to stay in pure JavaScript you can use Node.js. There are file manipulation libraries you can use.
Headless Browsers - Haven't thought through being able to save the resulting HTML automatically but you can use something like jsTestDriver or Phantom.js
You can go with the plugins in editors as well, but I would stick with a Java, C#, python, etc. library that you can potentially call from existing application or schedule as a job/service.
I need to add in a WYSIWYG control into a .NET form. I found this one from SpiceLogic on several sites and was wondering if this is a decent library to use?
http://www.spicelogic.com/Products/NET-Win-HTML-Editor-Control-8/
If anyone has any additional input, I also would like to know of any other decent alternatives, both free and non-free.
Thanks in advance for any opinions on this!
EDIT Should have clarified this before, but this is a desktop application.
You can also try one of these strategies:
Use the RichTextBox control, which exposes a FlowDocument. Write a program that converts the FlowDocument to HTML. Since FlowDocs are much more constrained that HTML, this conversion might be pretty straightforward (sections -> div, paragraph -> p, styles -> css or style attributes, etc).
Use MSHTML and put it into edit mode. http://msdn.microsoft.com/en-us/library/aa753622(v=vs.85).aspx
You may want to try XStandard. I have used it in CMS web sites and it works great. You can also use it with desktop apps. There is a free "lite" version and a for=pay pro version. It creates XHTML markup and has lots of slick built-in functionality.
As a comparison, I have used Telerik RAD Editor and XStandard is much better (IMO). I have also tried other web-specific solutions like FCKEditor and TinyMCE and I prefer XStandard.
If your concern is to get XHTML all the time right from the beginning which should be published on the Web, then, I would say, "Yes", you can try that component from SpiceLogic, especially the version 5.x which was released very recently. It comes with many features like embedding images for an email client, Uploading local images to FTP, paste from MS Word, rich Dialogs for Tables, Images, Hyperlink, Symbols, Inline Spell Checker and Spell Checker dialogs, and more.
https://www.spicelogic.com/Products/NET-WinForms-HTML-Editor-Control-8
All Screenshots:
http://www.spicelogic.com/Products/NET-WinForms-HTML-Editor-Control-8/Screenshots
TinyMCE is a great way to achieve this. Here is a way to embed TinyMCE in Winform. I tested it and it works pretty well: https://github.com/Rocker93/winforms-html-editor
An other solution is CEFSharp. The integration is not easy but it's very well documented and it's the most powerful and free solution I have found.
At work we use telerik controls for this stuff:
http://www.telerik.com/products/aspnet-ajax/editor.aspx
its definitely not free though.
I am developing a web-based Pokemon Online game. Since it is online, I would like to optimize it to run as quickly possible.
I've installed Firebug and Page Speed suggests minifying my HTML output. I'm also using VS2008, ASP.NET 3.5, AJAX, and IIS 7.5; along with URL-Rewriting.
I want to minify my HTML, JavaScript, and CSS. Optimally, I'd like the minifying process to happen at compile time. I've spend hours looking online but couldn't find a decent solution, can you help me? Thank you.
Firstly, you should read the Yahoo best practices for speeding up webpages.
You will probably find that minifying the HTML won't have much difference (also see this question), but a lot of the other suggestions in that article will.
There are a couple of methods to achieve this. You can configure GZip compression with IIS7 if you have access. If you don't i.e. you are using a hosting provider it is possible to activate compression from within your code.
See this SO Post for further reading.
UPDATE:
To perform this at build time rather than run time see this blog post.
Instead of minifying your .aspx files consider dynamic compression. This will send compressed data to the browser. since you are using IIS 7.5 dynamic compression comes built-in you just have to enable it.
I have an ASP.net website ( http://www.erate.co.za ) version 2.0.
When someone opens my website in Firefox everything looks different.
Why is that and how can I make it compatible?
Please help!
Etienne
The problems don't have anything to do with ASP.NET / C# Specifically.
They have to do with your understanding of web design / HTML / CSS and how you can make a cross-browser compatible UI.
I'd suggest you look at http://www.w3schools.com/ for some information on good web design practices.
Some obvious problems with the Source that you need to address are
No common css Stylesheets
Styles are applied inline on lots of elements
using long strings of " " to align text
The underlying server technology should not have any impact on your websites appearence as long as you are just producing HTML.
What you need to do is make sure that your HTML and CSS works as intended in all browsers. A good way to start is to make sure that you only output standards compliant code.
The issue at hand is that styles that you are using don't work in firefox such as cursor:hand; versus cursor:pointer; both work in IE but only pointer works in firefox. A quick recommendation would be to just run the resultant page through the w3c validator located at: http://validator.w3.org/
Per se, ASP.NET produce vanilla HTML/Javascript, so there's nothing wrong with the technology.
Focus on the html, try to be as close as possible to the w3c standards, it should help a lot.
Firebug, an incredible web dev extension for Firefox should also help you a lot in debugging your CSS.
It might be a painful task, especially if your site is old and big. Good luck!