Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
compress javascript

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Sat Jul 02, 2011 2:35 pm    Post subject: compress javascript Reply with quote

Hello,

Is there a function to compress the javascript code ? As the {strip} for HTML

Tanks.
Back to top
View user's profile Send private message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Sat Jul 02, 2011 6:49 pm    Post subject: Reply with quote

Hmmm

This is the {literal} that prevents :s

Code:
<script type="text/javascript">
{literal}
jQuery(function($){
.....
});
{/literal}
</script>
Back to top
View user's profile Send private message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Sun Jul 03, 2011 9:44 am    Post subject: Reply with quote

No idea ?
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 698
Location: Germany, border to Switzerland

PostPosted: Sun Jul 03, 2011 1:02 pm    Post subject: Reply with quote

maybe https://github.com/pilif/sacy is what you're looking for?
otherwise you might want to build your own plugin with https://github.com/rgrove/jsmin-php/ and http://code.google.com/p/cssmin/
Back to top
View user's profile Send private message Visit poster's website
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Wed Aug 10, 2011 7:53 am    Post subject: Reply with quote

I install SACY, it will not work.

i'm using php 5.3.5.

Here is the error :

Quote:
[Wed Aug 10 09:46:38 2011] [error] [client 127.0.0.1] PHP Fatal error: Uncaught exception 'sacy_Exception' with message 'Cannot handle tag: ' in phar:///home/c4y/public_html/smarty1/smarty/plugins/block.asset_compile.php/sacy/sacy.php:184\nStack trace:\n#0 /home/c4y/public_html/smarty1/smarty/plugins/block.asset_compile.php(103): sacy_CacheRenderer->renderFiles(NULL, NULL, Array)\n#1 /home/c4y/public_html/smarty1/templates_c/fr^9206ffe216f3f7c2e7655782292928f7d20e8be5.file.footer.tpl.cache.php(4Cool: smarty_block_asset_compile(Array, '<script type="t...', Object(Smarty_Internal_Template), false)\n#2 /home/c4y/public_html/smarty1/smarty/sysplugins/smarty_internal_template.php(434): include('/home/c4y/pub...')\n#3 /home/c4y/public_html/smarty1/smarty/sysplugins/smarty_internal_template.php(569): Smarty_Internal_Template->renderTemplate()\n#4 /home/c4y/public_html/smarty1/templates_c/fr^90093ad09988b466f409a1871733c5589014713e.file.index.tpl.cache.php(85): Smarty_Internal_Template->getRenderedTemplate()\n#5 /home/c4y/public_html/smarty1/smarty/sysplugins/smarty_internal in phar:///home/c4y/public_html/smarty1/smarty/plugins/block.asset_compile.php/sacy/sacy.php on line 184


In TPL :
Code:
    {asset_compile}
        <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
        <script type="text/javascript" src="js/jquery-pngFix.min.js"></script>
    {/asset_compile}


One idea ?
Back to top
View user's profile Send private message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Sat Aug 13, 2011 10:42 am    Post subject: Reply with quote

no idea ???
Back to top
View user's profile Send private message
douglassdavis
Smarty Junkie


Joined: 21 Jan 2008
Posts: 524

PostPosted: Sat Aug 13, 2011 11:59 am    Post subject: Reply with quote

I don't know anything about sacy but I would say google the error message for ideas:

sacy_Exception Cannot handle tag
Back to top
View user's profile Send private message
pilif
Smarty n00b


Joined: 17 Sep 2009
Posts: 3

PostPosted: Mon Aug 15, 2011 12:21 pm    Post subject: Reply with quote

Author of sacy here: It looks to me like there is some unknown whitespace or an unknown tag in your {asset_compile} section.

Can you paste the full {asset_compile}-block here?

Philip
Back to top
View user's profile Send private message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Thu Aug 18, 2011 8:25 pm    Post subject: Reply with quote

Here is the code

Thank you for your help

Unable to copy the code here, oversize.
Back to top
View user's profile Send private message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Fri Aug 19, 2011 7:54 am    Post subject: Reply with quote

I use the file : block.asset_compile.php — Sacy 0.2 - All-in-on Bundle for PHP 5.3, excluding any transformation support. 46KB · Uploaded February 16, 2011

my block :
Code:
    {asset_compile}
        <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
        <script type="text/javascript" src="js/jquery-pngFix.min.js"></script>
    {/asset_compile}


In the file I see :




Is it be possible to have the file in UTF-8 compatible with the Linux system?

Tanks.
Back to top
View user's profile Send private message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Fri Aug 26, 2011 9:03 am    Post subject: Reply with quote

UUUUUP
Back to top
View user's profile Send private message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Sat Aug 27, 2011 10:13 am    Post subject: Reply with quote

The problem persists with this code

Code:
{asset_compile}
    <script type="text/javascript" src="js/jquery-1.6.2.js"></script>
{/asset_compile}
Back to top
View user's profile Send private message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Tue Sep 13, 2011 8:54 am    Post subject: Reply with quote

UUUUUUUUUUUUUUUP
Back to top
View user's profile Send private message
jacz
Smarty Pro


Joined: 13 Nov 2010
Posts: 249

PostPosted: Tue Sep 13, 2011 9:57 am    Post subject: Reply with quote

Tip:

Never use a script to compress javascript online within a website , the costs are higher as you win something.

Use Google Pagespeed , if there are Minify JavaScript violations, download compressed js from Google and change it for you - only one time and never again.

And use async or defer if is possible and you win a lot of time.

Use application cache and you have a private cdn.

Look at here - a smarty 3.1RC1 Web, hostet in Germany, shown and rendered in Wellington, New Zealand on the other side of the world, heavy js work and look at the second call, that was ready in 0,23 seconds.

http://www.webpagetest.org/result/110913_K7_1K2H2/

In this things you should invest time.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP