English 中文(简体)
从事较低或专门化工作的最佳做法
原标题:Best practice for working with less, or minified CSS

我在考虑在即将到来的项目中使用较少的资源,但一直试图找出在发展中与它合作的最佳途径。

Usually when developing a site I ll write my html and css then start testing it in the browser, see how it looks, refine, reload, and repeat the whole process until I m happy with how everything looks.

A crucial part of the process is using the Inspect Element feature in the browser to identify the piece of CSS I need to change. Usually just by looking at the line number I know exactly where to go in my CSS file.

但是,如果我使用较少(或采用任何其他方法合并/压缩我的特别安全局),那么线数便无用。 我知道,我可以使用Find搜索法典的章节,但线数要更快。

在开展涉及其他开发商或大型公司档案的项目时尤其如此。

我只想知道其他人是如何处理这个问题的,或者也许会有一个更好的进程?

问题回答

Minified CSS really should only be going out to the production version of your site. When you re performing tests/changes etc, this should all be done in some test or development version of your site in a secondary server area where you can have the line-numbers version of css available. The same would go for JavaScript. On the production viewable copy, you want it minified. In development, you don t.

无论如何,你应始终有两本。 第一份副本是主要资料来源,是您的编写本。 它有你妥善的风格,有条不紊。 另一种是你生产工艺的最新精炼版本。 这将使你在需要做事时能够迅速从2个档案中取而代之,假定贵网站使用某种模板式交付(下页、总页或任何)。

The minified version will only be useful in the final delivery. All other needs should use the master copy. It might not be a bad idea to put a configuration in server-side portion of your site that determines what style sheet to use. That way you can simply change a configuration setting and go into a "debug" mode.

我同意Joel的看法,即我是如何处理这一问题的。 在每次释放之前,每释放一个建筑材料小型公司(and JS)就开始生产。 我刚刚在购买力平价中转过了:

if ($config->prod()) {
    // incldue the minfied css
} else {
    // include all the original files
}

在个人方面,我使用的是一只ant的造物,以形成一种生产版本:

  1. it "condense" multiple css files in one
  2. then it minify them with YUI compressor
  3. same for scripts
  4. (page recomposition to point to the newly generated files)

this way you divide your http request for those files, and gain some bandwith from 30% to 70% i d say. depends on gzip also.

in my case, the dev version have: 18 css weighting 178ko reduced down to 1 css at 96ko in the production version

我个人利用各种工具,每次节省我小的档案时,都把安保部提炼并注入浏览器。 因此,我立即看到每一种变化。 这样一来,它就清醒了刚刚发生的事情。 我不需要更多的参考线号码。

最近,我开始使用以下网站:https://developers.google.com/chlowe-Develper-tools/docs/css-preprocessors” conf=“no followlow”来源地图:>a>,以便在再次检查电灯时看到正确文档和线号(我较少的档案)。 我们认为,这是你所期待的。 我个人不需要如此大的fan。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签