preg_replace() compress css code in pagine

Ai o întrebare legată de PHP? Incercăm să îi găsim soluţie. Sau poate doar vrei să publici un cod interesant.

Moderatori: Zamolxe, Moderatori

XDYNX
Senior Member
Mesaje: 518
Membru din: Joi Iun 08, 2006 6:01 pm
Localitate: Pitesti
Contact:

preg_replace() compress css code in pagine

Mesajde XDYNX » Joi Ian 19, 2017 4:40 pm

Am un plugin care adaugi niste regex cod, ceva de genul si iti replace in site....


A mapping of PHP regular expressions to replacement values which are executed on all blog HTML after WordPress finishes emitting the entire page. The pattern and replacement behavior is in the manner of preg_replace().

The following example removes all HTML comments in the first pattern, and causes a favicon (with any filename extension) to be loaded from another domain in the second pattern:
#<!--.*?-->#s =>
#\bsrc="/(favicon\..*)"# => src="http://mycdn.somewhere.com/$1"



Eu am incercat
#<!--.*?-->#s =>
/^[ \t]*[\r\n]+/m =>

Asta #<!--.*?-->#s => elimina comentarile
Si asta /^[ \t]*[\r\n]+/m => scoate linile goale

Acum vreau sa comprime codul css din pagina ? puteti sa ma ajutati


Iona14:6 Isus i-a zis: "Eu sunt Calea, Adevarul si Viata. Nimeni nu vine la Tatal decat prin Mine.

Avatar utilizator
vectorialpx
Senior Member
Mesaje: 4832
Membru din: Mar Mar 01, 2005 9:48 am
Localitate: Bucuresti
Contact:

Re: preg_replace() compress css code in pagine

Mesajde vectorialpx » Mie Ian 25, 2017 11:10 pm

Comprimarea nu o faci tu, o face serverul - banuiesc ca te referi la gzip
http://stackoverflow.com/questions/9558 ... ile-in-php

nevvermind
Senior Member
Mesaje: 1264
Membru din: Mar Iun 22, 2010 3:17 pm

Re: preg_replace() compress css code in pagine

Mesajde nevvermind » Joi Ian 26, 2017 11:36 am

Cred ca vrea "minified".
Facusi un canal de php pe freenode - ##php-ro : https://webchat.freenode.net/


Înapoi la “Cod PHP”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 39 vizitatori